<template>
    <div>
        <el-table :data="reciteStudentList"  v-loading="loading"  
            highlight-current-row height="300" 
            @current-change="handleSelectionChange">
            <el-table-column
              label="学生编号"
              align="center"
              prop="id"
            />
            <el-table-column
              label="学生姓名"
              align="center"
              prop="studentName"
            />
        </el-table>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="submitHelpStuList">确 定</el-button>
        </span>
    </div>
  </template>
  
  <script>
    import {queryClassStudents} from "@/api/exam/examResultEnter";
    import {addHelp} from "@/api/evaluation/help"
  
  export default {
    name: "classStudentList",
    props:{
        row:{
            type:Object,
            default:{}
        }
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        reciteStudentList:[],
        selectRow:[]
      };
    },
    created() {
      this.getClassStudent();
    },
    methods: {
        /**table多选 */
        handleSelectionChange(val) {
            this.selectRow = val;
            console.log(val)
        },
        submitHelpStuList(){
            if(!this.selectRow){
                this.$message({
                    message: '请选择一条记录',
                    type: 'warning'
                });
                return
            }
            let data={
                studentId: this.row.studentId,
                studentName: this.row.studentName,
                helpStudentId: this.selectRow.id,
                helpStudentName: this.selectRow.studentName,
                classId: this.selectRow.classId,
                className: this.selectRow.className
            }
            addHelp(data).then(resp=>{
                if(resp.code==200){
                    this.msgSuccess("提交成功")
                    //关闭窗口
                    this.$emit("handleCloseHelp")
                }
            })
        },
        getClassStudent() {
            this.loading = true
            this.reciteStudentList=[]
            queryClassStudents({ classId: this.row.classId }).then((resp) => {
                this.reciteStudentList = resp.data
                this.loading = false
            });
        },
      
    }
  };
  </script>
  